package cn.micai.base.io;

import org.apache.commons.io.FilenameUtils;
import java.io.File;

/**
 * 描述：
 * <p>
 *
 * @author: 赵新国
 * @date: 2018/6/7 10:10
 */
public class GetFileExtensionApache {

    public static void main(String [] args) {
        ClassLoader classLoader = GetFileExtensionApache.class.getClassLoader();

        File file = new File(classLoader.getResource("test.txt").getFile());
        String fileExtension = FilenameUtils.getExtension(file.getName());
        System.out.println("File extension for test.txt is "+ fileExtension);

        File httpFile = new File(classLoader.getResource("HTTP Request.jmx").getFile());
        String extensionOfFile = FilenameUtils.getExtension(httpFile.getName());
        System.out.println("File extension for HTTP Request.jmx is "+ extensionOfFile);

        File folder=new File("src/main/resources");
        String fileExtensionFolder=FilenameUtils.getExtension(folder.getName());
        System.out.println("File extension for src/main/resources is "+fileExtensionFolder);
    }
}
